﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using DAL;
public partial class Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Page.DataBind();
    }


    protected void IbtnLogin_Click(object sender, ImageClickEventArgs e)
    {
        string userName = this.txtusername.Text;
        bool isExist = ClientManage.isExistUser(userName);
        if (isExist) {
            User u= ClientManage.CheckPass(userName,this.txtPassword.Text);
            if (u!=null) {
                Session["UserType"] = u.typeId;
                Session["UserId"] = u.UserId;
                Session["pId"] = u.pId;
                Response.Redirect("Index.aspx");
            }
            else
            {
                Response.Write("<script>alert('密码错误');</script>");
            }
        }
        else
        {
            Response.Write("<script>alert('用户不存在');</script>");
        }
    }
}